import collections
class lruCache:
    def __init__(self,capacity):
        self.capacity=capacity
        self.queue=collections.OrderedDict()
    def get(self,key):
        if key not in self.queue:
            return -1
        value=self.queue.pop(key)
        self.queue[key]=value
        return self.queue[key]
    def put(self,key,value):
        if key in self.queue:
            self.queue.pop(key)
        elif len(self.queue.items())==self.capacity:
            self.queue.popitem(last=False)
        self.queue[key]=value
mylru=lruCache(5)
mylru.put(3,9)
print(mylru.get(5))
mylru.put(5,10)
print(mylru.get(5)) 